package com.ruoyi.flow.service.de;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.ruoyi.flow.model.de.ProdDeModel;
import com.ruoyi.flow.tools.pager.PagerModel;
import com.ruoyi.flow.tools.pager.Query;
import org.flowable.bpmn.model.BpmnModel;

import java.util.List;

/**
 * @title:
 * @author: bruce.liu
 * @since: 2023/5/9 23:44
 */
public interface ProdDeModelService extends IService<ProdDeModel> {
    /**
     * 通过key来更新表达式名称
     * @param modelKey modelKey
     * @param processNameExp processNameExp
     */
    void updateProcessNameExpByKey(String modelKey, String processNameExp) ;
    /**
     * 判断是否存在
     * @param modelKey modelKey
     * @return
     */
    Integer getDeModelCount(String modelKey) ;
    /**
     * 拷贝流程模板
     * @param id id
     * @param model model
     * @return
     */
    ProdDeModel duplicateModel(String id, ProdDeModel model);
    /**
     * 通过key获取模型
     *
     * @param modelType modelType
     * @param key       key
     * @return
     */
    ProdDeModel getModelByKey(Integer modelType, String key);
    ProdDeModel getBpmnModelByKey(String key);
    ProdDeModel getDmnModelByKey(String key);
    ProdDeModel getModelByIdOrKey(Integer modelType, String id, String key) ;

    /**
     * 查询分页model对象
     * @param model model
     * @param query
     * @return
     */
    PagerModel<ProdDeModel> queryPagerModel(ProdDeModel model, Query query)  ;

    /**
     * 查询分页model对象
     * @param model model
     * @param page query
     * @return
     */
    Page<ProdDeModel> queryPagerModel(ProdDeModel model, Page page)  ;

    /**
     * 验证modelkey
     *
     * @param modelType modelType
     * @param modelKey  modelKey
     * @return
     */
    boolean validateModelKey(Integer modelType, String modelKey);
    List<ProdDeModel> getModelsByModelType(Integer modelType) ;

    /**
     * 通过model获取字节数组
     *
     * @param bpmnModel bpmnModel
     * @return
     */
    byte[] getBpmnXMLByte(BpmnModel bpmnModel);

    /**
     * 通过bpmnmodel获取xml文件
     *
     * @param bpmnModel bpmnModel
     * @return
     */
    String getBpmnXML(BpmnModel bpmnModel);

    BpmnModel exportAndReadXMLFile(BpmnModel model);

    /**
     * 通过xml 获取bpmnmodel
     *
     * @param xml xml
     * @return
     */
    BpmnModel getBpmnModelByXml(String xml);

    /**
     * 修改状态
     * @param id id
     * @param status status
     */
    void updateStatusById(String id, String status) ;

    /**
     * 通过分类的codes查询流程的数量
     * @param categoryCodes categoryCodes
     * @return
     */
    long getFlowCountByCategoryCodes(List<String> categoryCodes);
}
